/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.facilscrum.form.sprint;

import java.text.SimpleDateFormat;
import javax.swing.table.DefaultTableModel;
import org.javscaz.javscaztools.utilidades.Utilidades;
import org.facilscrum.beans.Proyectos;
import org.facilscrum.beans.Sprint;
import org.facilscrum.beans.Userstories;
import org.facilscrum.beans.Userstoriessprint;
import org.facilscrum.controller.ProyectosController;
import org.facilscrum.controller.SprintController;
import org.facilscrum.controller.UserstoriesController;
import org.facilscrum.controller.UserstoriessprintController;
import org.facilscrum.generales.Mensajeria;
import org.facilscrum.sesion.MySesion;
import sun.security.ec.ECDHKeyAgreement;

/**
 *
 * @author avbravo
 */
public class UserStoriesSprintAgregarForm extends javax.swing.JInternalFrame {

    Proyectos proyectos = new Proyectos();
    ProyectosController proyectosController = new ProyectosController();
    Sprint sprint = new Sprint();
    SprintController sprintController = new SprintController();
    Userstories userstories = new Userstories();
    UserstoriesController userstoriesController = new UserstoriesController();
    Userstoriessprint userstoriessprint = new Userstoriessprint();
    UserstoriessprintController userstoriessprintController = new UserstoriessprintController();
    DefaultTableModel modelo, modeloDisponible;
    Boolean fueMovido = false;
    Integer totalPuntosAsignados = 0;
    Integer velocidad = 0;
    Integer puntosLibres = 0;

    /**
     * Creates new form SprintForm
     */
    public UserStoriesSprintAgregarForm() {
        initComponents();
        fueMovido = false;
        modeloDisponible = (DefaultTableModel) jTableUserStoriesDisponibles.getModel();
        modelo = (DefaultTableModel) jTableUserStoriesAsignados.getModel();
        jButtonGuardar.setEnabled(true);


        java.util.Calendar ca = java.util.Calendar.getInstance();
        java.sql.Date mydate = new java.sql.Date(ca.getTimeInMillis());
        jXDatePickerFechaInicio.setDate(mydate);
        jXDatePickerFechaInicio.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        jXDatePickerFechaTerminacion.setDate(mydate);
        jXDatePickerFechaTerminacion.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        jXDatePickerFechaDemo.setDate(mydate);
        jXDatePickerFechaDemo.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
        if (!MySesion.getSeleccionoProyectoTrabajo()) {
            Mensajeria.MensajeWarning("Debe indicar el proyecto de trabajo");
        } else {
            proyectos = MySesion.getProyectos();
            jTextFieldProyecto.setText(proyectos.getProyecto());
            jButtonGuardar.setEnabled(true);
            cargarComboSprint();
            cargarTablaUserStoriesDisponibles();
            cargarTablaUserStoriesAsignados();
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jFormattedTextFieldVelocidadEstimada = new javax.swing.JFormattedTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldPuntosAsigandos = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jXDatePickerFechaInicio = new org.jdesktop.swingx.JXDatePicker();
        jLabel5 = new javax.swing.JLabel();
        jXDatePickerFechaTerminacion = new org.jdesktop.swingx.JXDatePicker();
        jLabel9 = new javax.swing.JLabel();
        jXDatePickerFechaDemo = new org.jdesktop.swingx.JXDatePicker();
        jLabel6 = new javax.swing.JLabel();
        jFormattedTextFieldHoraDemo = new javax.swing.JFormattedTextField();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableUserStoriesDisponibles = new javax.swing.JTable();
        jButtonSubir = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTableUserStoriesAsignados = new javax.swing.JTable();
        jButtonQuitar = new javax.swing.JButton();
        jButtonGuardar = new javax.swing.JButton();
        jButtonRegresar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldProyecto = new javax.swing.JTextField();
        jComboBoxSprint = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaObjetivo = new javax.swing.JTextArea();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldPuntosDisponibles = new javax.swing.JTextField();

        setClosable(true);
        setTitle("Agregar User stories a Sprint");

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setText("Velocidad Estimada");

        jFormattedTextFieldVelocidadEstimada.setEditable(false);
        jFormattedTextFieldVelocidadEstimada.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("####"))));
        jFormattedTextFieldVelocidadEstimada.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N

        jLabel7.setText("Puntos asignados");

        jTextFieldPuntosAsigandos.setEditable(false);
        jTextFieldPuntosAsigandos.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jTextFieldPuntosAsigandos.setForeground(javax.swing.UIManager.getDefaults().getColor("CheckBoxMenuItem.selectionBackground"));

        jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel4.setText("Inicio");

        jXDatePickerFechaInicio.setEnabled(false);

        jLabel5.setText("Terminacion");

        jXDatePickerFechaTerminacion.setEnabled(false);

        jLabel9.setText("Fecha demo");

        jXDatePickerFechaDemo.setEnabled(false);

        jLabel6.setText("Hora demo");

        jFormattedTextFieldHoraDemo.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("H:mm"))));
        jFormattedTextFieldHoraDemo.setText("03:00");
        jFormattedTextFieldHoraDemo.setEnabled(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel9)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jXDatePickerFechaTerminacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jXDatePickerFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXDatePickerFechaDemo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jFormattedTextFieldHoraDemo, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jXDatePickerFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jXDatePickerFechaTerminacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel9))
                    .addComponent(jXDatePickerFechaDemo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jFormattedTextFieldHoraDemo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTableUserStoriesDisponibles.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Agregar", "id", "Nombre", "Imp.", "Puntos", "Autor"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTableUserStoriesDisponibles);
        jTableUserStoriesDisponibles.getColumnModel().getColumn(0).setMaxWidth(100);
        jTableUserStoriesDisponibles.getColumnModel().getColumn(1).setMaxWidth(60);
        jTableUserStoriesDisponibles.getColumnModel().getColumn(3).setMaxWidth(100);
        jTableUserStoriesDisponibles.getColumnModel().getColumn(4).setMaxWidth(60);

        jButtonSubir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/up.gif"))); // NOI18N
        jButtonSubir.setToolTipText("Agregar");
        jButtonSubir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSubirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 804, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonSubir)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addComponent(jButtonSubir)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTableUserStoriesAsignados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Quitar", "id", "Nombre", "Imp.", "Puntos", "Autor"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane4.setViewportView(jTableUserStoriesAsignados);
        jTableUserStoriesAsignados.getColumnModel().getColumn(0).setMaxWidth(100);
        jTableUserStoriesAsignados.getColumnModel().getColumn(1).setMaxWidth(60);
        jTableUserStoriesAsignados.getColumnModel().getColumn(3).setMaxWidth(100);
        jTableUserStoriesAsignados.getColumnModel().getColumn(4).setMaxWidth(60);

        jButtonQuitar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/flechaabajo.gif"))); // NOI18N
        jButtonQuitar.setToolTipText("Quitar");
        jButtonQuitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonQuitarActionPerformed(evt);
            }
        });

        jButtonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/save_icon.gif"))); // NOI18N
        jButtonGuardar.setToolTipText("Guardar");
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jButtonRegresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/avbravo/jscrum/gif/return.gif"))); // NOI18N
        jButtonRegresar.setToolTipText("Regresar");
        jButtonRegresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegresarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 804, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 24, Short.MAX_VALUE))
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonQuitar)
                .addGap(185, 185, 185)
                .addComponent(jButtonGuardar, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(jButtonRegresar, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonGuardar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jButtonQuitar)
                        .addContainerGap())
                    .addComponent(jButtonRegresar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Proyecto");

        jLabel10.setText("Sprint");

        jLabel2.setText("Objetivo");

        jTextFieldProyecto.setEnabled(false);

        jComboBoxSprint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxSprintActionPerformed(evt);
            }
        });

        jTextAreaObjetivo.setColumns(20);
        jTextAreaObjetivo.setRows(5);
        jTextAreaObjetivo.setEnabled(false);
        jScrollPane1.setViewportView(jTextAreaObjetivo);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jComboBoxSprint, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(24, 24, 24)))))
                .addGap(0, 12, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldProyecto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jComboBoxSprint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );

        jLabel8.setText("Puntos Disponibles");

        jTextFieldPuntosDisponibles.setEditable(false);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jFormattedTextFieldVelocidadEstimada, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)
                        .addGap(4, 4, 4)
                        .addComponent(jTextFieldPuntosAsigandos, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldPuntosDisponibles, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(26, 26, 26)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel7)
                        .addComponent(jTextFieldPuntosAsigandos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel8)
                        .addComponent(jTextFieldPuntosDisponibles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(jFormattedTextFieldVelocidadEstimada, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(33, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBoxSprintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSprintActionPerformed
        try {
            int j = jComboBoxSprint.getSelectedIndex();
            if (j != -1) {
                if (fueMovido) {
                    if (Mensajeria.PreguntaSiNo("Se realizo un cambio en los usuarios\nDesea guardar estos cambios\nAntes de realizar otra accion", "Guardar Cambios").equals("si")) {
                        guardar();
                    }
                    fueMovido = false;
                }
                sprint = sprintController.getSprintlist().get(j);
                jTextAreaObjetivo.setText(sprint.getObjetivo());
                jFormattedTextFieldVelocidadEstimada.setText(sprint.getVelocidadestimada().toString());
                jFormattedTextFieldVelocidadEstimada.setText(sprint.getVelocidadestimada().toString());
                jFormattedTextFieldHoraDemo.setText(sprint.getHorademo().toString());
                jXDatePickerFechaInicio.setDate(sprint.getFechainicio());
                jXDatePickerFechaInicio.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jXDatePickerFechaTerminacion.setDate(sprint.getFechaterminacion());
                jXDatePickerFechaTerminacion.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jXDatePickerFechaDemo.setDate(sprint.getFechademo());
                jXDatePickerFechaDemo.setFormats(new SimpleDateFormat("dd/MM/yyyy"));
                jTextFieldPuntosAsigandos.setText(sprint.getPuntosasignados().toString());


                cargarTablaUserStoriesDisponibles();
                cargarTablaUserStoriesAsignados();
                jButtonGuardar.setEnabled(true);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "comboProyecto()");
        }
    }//GEN-LAST:event_jComboBoxSprintActionPerformed

    private void jButtonRegresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegresarActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonRegresarActionPerformed

    private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed
        guardar();
    }//GEN-LAST:event_jButtonGuardarActionPerformed

    private void jButtonSubirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSubirActionPerformed
        try {
            moverUserstoriesModelo();
            fueMovido = true;
//            if (modeloDisponible.getRowCount() == 0) {
//                jButtonSubir.setEnabled(false);
//            }
            jButtonGuardar.setEnabled(true);
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "subir()");
        }
    }//GEN-LAST:event_jButtonSubirActionPerformed

    private void jButtonQuitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQuitarActionPerformed
        try {


            quitarUserstoriesModelo();
            fueMovido = true;
//            if (!jButtonSubir.isEnabled()) {
//                jButtonSubir.setEnabled(true);
//            }
//            if (modeloDisponible.getRowCount() == 0) {
//                jButtonQuitar.setEnabled(false);
//            }
            jButtonGuardar.setEnabled(true);
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "quitar()");
        }
    }//GEN-LAST:event_jButtonQuitarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonQuitar;
    private javax.swing.JButton jButtonRegresar;
    private javax.swing.JButton jButtonSubir;
    private javax.swing.JComboBox jComboBoxSprint;
    private javax.swing.JFormattedTextField jFormattedTextFieldHoraDemo;
    private javax.swing.JFormattedTextField jFormattedTextFieldVelocidadEstimada;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTable jTableUserStoriesAsignados;
    private javax.swing.JTable jTableUserStoriesDisponibles;
    private javax.swing.JTextArea jTextAreaObjetivo;
    private javax.swing.JTextField jTextFieldProyecto;
    private javax.swing.JTextField jTextFieldPuntosAsigandos;
    private javax.swing.JTextField jTextFieldPuntosDisponibles;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaDemo;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaInicio;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerFechaTerminacion;
    // End of variables declaration//GEN-END:variables

    /*
     * cargarComoboSprint()
     */
    private Boolean cargarComboSprint() {
        try {

            jComboBoxSprint.removeAllItems();

            String where = "idproyecto='" + proyectos.getIdproyecto() + "' and abierto='si' ";

            if (sprintController.query(where)) {
                for (Sprint s : sprintController.getSprintlist()) {
                    jComboBoxSprint.addItem(s.getIdsprint() + " - " + s.getNombre());
                }
                return true;
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarComboSprint() ");

        }
        return false;
    }

    private void cargarTablaUserStoriesAsignados() {
        try {
            jButtonGuardar.setEnabled(false);
            modelo = Utilidades.limpiarModelo(modelo);
            String where = "idsprint='" + sprint.getIdsprint() + "'";
            if (userstoriessprintController.query(where)) {
                for (Userstoriessprint u : userstoriessprintController.getUserstoriessprintlist()) {
                    Object[] filas = new Object[6]; // Hay tres columnas en la tabla       
                    filas[0] = false;
                    filas[1] = u.getIduserstories();
                    filas[2] = u.getUserstories().getNombre();
                    filas[3] = u.getUserstories().getImportancia();
                    filas[4] = u.getUserstories().getPuntos();
                    filas[5] = u.getUserstories().getUsuarios().getNombre();
                    modelo.addRow(filas);
                }
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarTablaUserStoriesAsignados()");
        }
    }
    /*
     *  cargarTablaUserStories()
     */

    private void cargarTablaUserStoriesDisponibles() {
        try {
            jButtonGuardar.setEnabled(false);
            modeloDisponible = Utilidades.limpiarModelo(modeloDisponible);
            String where = "idproyecto='" + proyectos.getIdproyecto() + "' and asignado='no'";
            if (userstoriesController.query(where)) {
                for (Userstories u : userstoriesController.getUserstorieslist()) {
                    Object[] filas = new Object[6]; // Hay tres columnas en la tabla       
                    filas[0] = false;
                    filas[1] = u.getIduserstories();
                    filas[2] = u.getNombre();
                    filas[3] = u.getImportancia();
                    filas[4] = u.getPuntos();
                    filas[5] = u.getUsuarios().getNombre();
                    modeloDisponible.addRow(filas);
                }
                jButtonGuardar.setEnabled(true);
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "cargarTablaUserStories()");
        }
    }

    private void guardar() {
        try {

            eliminarUserstoriessprintTabla();
            agregarUserstoriessprintTabla();
            calcularPuntosAsignados();
            sprint.setPuntosasignados(totalPuntosAsignados);
            if (!sprintController.update(sprint)) {
                Mensajeria.MensajeWarning("No se pudo actualizar el total de puntos en el sprint\n" + sprintController.getMensaje());
            }
            Mensajeria.Mensaje("Proceso finalizado");
//            limpiar();
            cargarTablaUserStoriesDisponibles();
            cargarTablaUserStoriesAsignados();
            fueMovido = false;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "guardar()");
        }

    }

    private void limpiar() {
        jTextAreaObjetivo.setText("");
        jFormattedTextFieldVelocidadEstimada.setText("0");
        jFormattedTextFieldHoraDemo.setText("03:00");
        jTextFieldPuntosAsigandos.setText("0");
    }

    /*
     * 
     */
    public void calcularPuntosAsignados() {
        try {
            totalPuntosAsignados = 0;
            for (int i = 0; i < modelo.getRowCount(); i++) {
                totalPuntosAsignados += Integer.parseInt(modelo.getValueAt(i, 4).toString());
            }
            jTextFieldPuntosAsigandos.setText(totalPuntosAsignados.toString());
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "calcularPuntosAsignados()");
        }
    }

    public Boolean validarPuntos() {
        try {
            calcularPuntosAsignados();

            velocidad = Integer.parseInt(jFormattedTextFieldVelocidadEstimada.getText());
            if (totalPuntosAsignados >= velocidad) {
                Mensajeria.MensajeWarning("No se pueden asignar mas userstories al sprint\nYa se cumplio el total de puntos de la velocidad estimada");
                return false;
            }
            puntosLibres = velocidad - totalPuntosAsignados;
            jTextFieldPuntosDisponibles.setText(puntosLibres.toString());


            Integer puntos = 0;
            String temp;
            for (int i = 0; i < modeloDisponible.getRowCount(); i++) {
                temp = modeloDisponible.getValueAt(i, 0).toString();
                if (temp.equals("true")) {
                    puntos += Integer.parseInt(modeloDisponible.getValueAt(i, 4).toString());
                }
            }
            if (puntos > puntosLibres) {
                Mensajeria.MensajeWarning("Se esta asignando puntos de mas a este sprint\nNo agregue todos los userstories seleccionados\nQuedan disponibles " + puntosLibres + " puntos");
                return false;
            }
            return true;
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "validarPuntos()");
        }
        return false;
    }

    private void moverUserstoriesModelo() {
        try {

            int n = modeloDisponible.getRowCount();
            if (n == 0 || !Utilidades.tieneSeleccionados(modeloDisponible, 0)) {
                Mensajeria.MensajeWarning("No hay userstories disponibles para agregarlos");
                return;
            }
            if (!validarPuntos()) {
                return;
            }
            String temp;
            for (int i = 0; i < modeloDisponible.getRowCount(); i++) {
                temp = modeloDisponible.getValueAt(i, 0).toString();
                if (temp.equals("true")) {
                    Object[] filas = new Object[6]; // Hay tres columnas en la tabla       
                    filas[0] = false;
                    filas[1] = modeloDisponible.getValueAt(i, 1).toString();
                    filas[2] = modeloDisponible.getValueAt(i, 2).toString();
                    filas[3] = modeloDisponible.getValueAt(i, 3).toString();
                    filas[4] = modeloDisponible.getValueAt(i, 4).toString();
                    filas[5] = modeloDisponible.getValueAt(i, 5).toString();
                    modelo.addRow(filas);
                    modeloDisponible.removeRow(i);
                    i--;
                }

            }
            calcularPuntosAsignados();
            puntosLibres = velocidad - totalPuntosAsignados;
            jTextFieldPuntosDisponibles.setText(puntosLibres.toString());
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "moverUserstoriesModelo()");
        }
        return;
    }

    private void quitarUserstoriesModelo() {
        try {

            int n = modelo.getRowCount();
            if (n == 0 || !Utilidades.tieneSeleccionados(modelo, 0)) {
                Mensajeria.MensajeWarning("No hay userstories  para quitarlos ");
                return;
            }
            String temp;
            for (int i = 0; i < modelo.getRowCount(); i++) {
                temp = modelo.getValueAt(i, 0).toString();
                if (temp.equals("true")) {
                    Object[] filas = new Object[6];
                    filas[0] = false;
                    filas[1] = modelo.getValueAt(i, 1).toString();
                    filas[2] = modelo.getValueAt(i, 2).toString();
                    filas[3] = modelo.getValueAt(i, 3).toString();
                    filas[4] = modelo.getValueAt(i, 4).toString();
                    filas[5] = modelo.getValueAt(i, 5).toString();
                    modeloDisponible.addRow(filas);
                    modelo.removeRow(i);
                    i--;
                }
            }
            calcularPuntosAsignados();
            puntosLibres = velocidad - totalPuntosAsignados;
            jTextFieldPuntosDisponibles.setText(puntosLibres.toString());
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "quitarUsuarios()");
        }
        return;
    }
    /*
     * eliminarUserstoriessprintTabla
     */

    private Boolean eliminarUserstoriessprintTabla() {
        try {

            UserstoriessprintController userstoriessprintController1 = new UserstoriessprintController();
            UserstoriesController userstoriesController1 = new UserstoriesController();
            int n = modelo.getRowCount();
            String where = "";
            Integer iduserstories = 0;
            /*
             *verificar los que se eliminaron
             */
            where = "idsprint ='" + sprint.getIdsprint() + "'";
            if (n != 0) {
                // si se quitaron usuarios del modelo
//                where = "idsprint ='" + sprint.getIdsprint() + "'";
                if (userstoriessprintController1.query(where)) {
                    for (Userstoriessprint u : userstoriessprintController1.getUserstoriessprintlist()) {
                        Boolean encontrado = false;
                        for (int i = 0; i < modelo.getRowCount(); i++) {
                            iduserstories = Integer.parseInt(modelo.getValueAt(i, 1).toString());
                            if (u.getIduserstories().equals(iduserstories)) {
                                encontrado = true;
                                break;
                            }
                        }
                        if (!encontrado) {
                            String query = "idsprint ='" + sprint.getIdsprint() + "' and iduserstories='" + u.getIduserstories() + "'";
                            if (!userstoriessprintController1.delete(query)) {
                                Mensajeria.MensajeWarning("No se pudo eliminar el userstoriessprint " + userstoriessprintController1.getMensaje());
                                break;
                            }
                            String sql = "asignado='no' where iduserstories='" + u.getIduserstories() + "'";

                            if (!userstoriesController1.update(sql)) {
                                Mensajeria.MensajeWarning("No se pudo actualizar el estatus del userstories " + u.getIduserstories() + "\n" + userstoriesController1.getMensaje());
                            }
                        }
                    }
                }

            } else {
                //si tenia usuarios en este equipo y no hay en la tabla
                if (userstoriessprintController1.query(where)) {
                    for (Userstoriessprint u : userstoriessprintController1.getUserstoriessprintlist()) {
                        String sql = "asigando='no' where iduserstories='" + u.getIduserstories() + "'";
                        if (!userstoriesController1.update(sql)) {
                            Mensajeria.MensajeWarning("No se pudo actualizar el estatus del userstories " + u.getIduserstories());
                        }
                    }
                    if (!userstoriessprintController1.delete(where)) {
                        Mensajeria.MensajeWarning("No se pudieron quitar todos userstories " + userstoriessprintController1.getMensaje());
                    }
                }
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "eliminarUserstoriessprintTabla()");
        }
        return false;

    }

    private Boolean agregarUserstoriessprintTabla() {
        try {
            Userstoriessprint userstoriessprint1 = new Userstoriessprint();
            UserstoriessprintController userstoriessprintController1 = new UserstoriessprintController();
            UserstoriesController userstoriesController1 = new UserstoriesController();
            int n = modelo.getRowCount();
            String where;
            Integer iduserstories = 0;
            if (n != 0) {
                for (Integer i = 0; i < modelo.getRowCount(); i++) {
                    iduserstories = Integer.parseInt(modelo.getValueAt(i, 1).toString());
                    where = "idsprint ='" + sprint.getIdsprint() + "' and iduserstories='" + iduserstories + "'";
                    if (!userstoriessprintController1.query(where)) {
                        userstoriessprint1.setEstatus("pendiente");
                        userstoriessprint1.setIdsprint(sprint.getIdsprint());
                        userstoriessprint1.setIduserstories(iduserstories);
                        if (!userstoriessprintController1.insert(userstoriessprint1)) {
                            Mensajeria.MensajeWarning("No se pudo asignar el userstoriessprint " + iduserstories + "\n" + userstoriessprintController1.getMensaje());
                        } else {
                            String sql = "asignado='si' where iduserstories='" + iduserstories + "'";
                            if (!userstoriesController1.update(sql)) {
                                Mensajeria.MensajeWarning("No se pudo actualizar el estatus del userstories " + iduserstories + "\n" + userstoriesController1.getMensaje());
                            }
                        }

                    }
                }
            }

        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "agregarUserstoriessprintTabla()");
        }
        return false;

    }

    private Boolean actualizarEstatusUserstories() {
        try {
            int n = jTableUserStoriesDisponibles.getRowCount();
            Integer guardados = 0;
            Integer actualizados = 0;
            Integer totalPuntos = 0;
            String temp;
            for (int i = 0; i < n; i++) {
                temp = jTableUserStoriesDisponibles.getValueAt(i, 0).toString();
                if (temp.equals("true")) {
                    guardados++;
                    userstories.setIduserstories(Integer.parseInt(jTableUserStoriesDisponibles.getValueAt(i, 1).toString()));
                    Userstories u = userstoriesController.findByPrimaryKey(userstories);
                    if (u != null) {

                        u.setAsignado("si");
                        if (userstoriesController.update(userstories)) {
                            totalPuntos += u.getPuntos();
                        } else {
                            Mensajeria.MensajeWarning("No se pudo actualizar el estatus " + userstoriesController.getMensaje());
                        }
                    } else {
                        Mensajeria.MensajeWarning("No pudo registrar el userstories al sprint " + userstoriesController.getMensaje());
                    }
                }
            }
            if (guardados != 0) {
                sprint.setPuntosasignados(sprint.getPuntosasignados() + totalPuntos);
                if (!sprintController.update(sprint)) {
                    Mensajeria.MensajeWarning("No se pudo actualizar el total de puntos en el sprint\n" + sprintController.getMensaje());
                    return false;
                }
                return true;
            }
        } catch (Exception ex) {
            Mensajeria.MensajeError(ex, "actualizarEstatusUserstories()");
        }
        return false;

    }
}
